Skip to content

Retry unanswered root handshakes sooner - #2641

Open
apkd wants to merge 1 commit into
zerotier:devfrom
apkd:fix/root-recovery
Open

apkd wants to merge 1 commit into
zerotier:devfrom
apkd:fix/root-recovery

Conversation

@apkd

@apkd apkd commented Nov 2, 2026

Copy link
Copy Markdown

Note

This pull request was prepared using AI. I've reviewed the patch and tried to keep it clean, but I admit the ZeroTier codebase is outside my expertise.

After waking from sleep or changing networks, ZeroTier can send a connection request (HELLO) before internet access returns. A saved path to a root server can then delay the next request by nearly four minutes.

This change retries sooner when a scheduled connection request goes unanswered or saved paths expire. It compares the send times in direct replies, so a delayed reply cannot acknowledge a newer scheduled request.

Tradeoffs

Recovery starts the five-second root retry cycle earlier, including after a lost reply. Upstream already uses this cycle when no saved paths remain. It sends requests to known IPv4 and IPv6 endpoints and probes saved paths; machines with several network interfaces may send extra copies.

Tests

One automated test simulates a lost request after sleep, followed by an old reply. It checks that ZeroTier reconnects promptly and avoids extra requests during healthy idle periods before and after recovery.

  • The full test suite passes in Linux release and AddressSanitizer builds.
  • The new test fails on the original code because recovery takes too long.

Related: #2082.

Unanswered root requests and expired paths trigger earlier retries, reducing reconnection delays after sleep or network changes. Reply tracking distinguishes delayed replies from replies to newer requests. Recovery completes after accepting the reply path.
@CLAassistant

CLAassistant commented Nov 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants